<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>${obj.projName }</title>
<link rel="shortcut icon" href="favicon.ico">
<!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>

<!-- 界面单独引入的其他样式和脚本 -->
<link rel="stylesheet"
	href="${path }/resource/plugin/zTree/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script type="text/javascript"
	src="${path }/resource/plugin/zTree/jquery.ztree.core-3.5.min.js"></script>

<script type="text/javascript"
	src="${path }/resource/plugin/syntaxhighlighter_3.0.83/scripts/shCore.js"></script>
<script type="text/javascript"
	src="${path }/resource/plugin/syntaxhighlighter_3.0.83/scripts/shBrushJScript.js"></script>
<link type="text/css" rel="stylesheet"
	href="${path }/resource/plugin/syntaxhighlighter_3.0.83/styles/shCore.css" />
<link type="text/css" rel="stylesheet"
	href="${path }/resource/plugin/syntaxhighlighter_3.0.83/styles/shCoreDefault.css" />
<script type="text/javascript">
	SyntaxHighlighter.all();
</script>
<style type="text/css">
.hkdg {
	width: 100px;
	height: 100px;
	margin: 5px;
	border: 1px solid #aeaeae;
	border-radius: 5px;
	padding: 3px;
	margin: 5px;
}

blockquote {
	font-size: 14px;
	line-height: 25px;
}

.title {
	color: #6f5499;
	font-size: 32px;
	text-shadow: 2px 3px 2px #ababab;
}
</style>
</head>

<body class="gray-bg">
	<div class="wrapper wrapper-content  animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<form class="form-horizontal" id="dataform"
					onsubmit="javascripr:return false;">
					<div class="form-group">
						<label class="col-sm-2 control-label">接口名称：</label>
						<div class="  col-sm-10">
							<p class="form-control-static">${obj.name }</p>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">请求方式：</label>
						<div class="  col-sm-10">
							<select class="form-control " name="method">
								<option value='GET'
									<c:if test="${obj.method eq 'GET' }"> selected="selected" </c:if>>GET</option>
								<option value='POST'
									<c:if test="${obj.method eq 'POST' }">selected="selected" </c:if>>POST</option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">访问URL：</label>
						<div class="  col-sm-8">
							<input class="form-control" value=" ${obj.url }" name="url">
						</div>
						<div class="  col-sm-2">
							<button type="button" onclick="req()"
								class="btn btn-success">执行请求</button>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">请求头：</label>
					 
						<div class="col-sm-10   col-sm-offset-2 ">
<textarea rows="2"  class="form-control"> </textarea>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">请求参数：</label>
				 
						<div class="col-sm-10  col-sm-offset-2 ">
							<textarea rows="5"  class="form-control"> <c:forEach var="item" items="${obj.paramList }" varStatus="count">
{ 
"${item.name}" :<c:if test="${item.paramType eq 'String'}"> "${item.exp}" </c:if> <c:if test="${item.paramType ne 'String'}"> 	${item.exp}  </c:if>
}
										</c:forEach> </textarea>
										<%--
										<td>${item.paramPosition}</td>
												<td>${item.defaultValue }</td>
												<td>${item.exp}</td>
												<td>${item.remark}</td>
											</tr><tr>
										<th width="50">序号</th>
										<th>名称</th>
										<th>类型</th>
										<th>是必须</th>
										<th>参数位置</th>
										<th>默认值</th>
										<th>示例</th>
										<th>备注</th>
									</tr>  --%> 
								 
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label  ">返回参数：</label>
						<div class="  col-sm-10">
							 <textarea readonly="readonly" class="form-control" id="result" rows="20" cols=""></textarea>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	
<script type="text/javascript" src="${path }/resource/js/fomatJs.js"></script>
	
	<script type="text/javascript">
	function req(){
		$
		.AjaxProxy({
			a : false,
			c : true
		})
		.invoke(
				"${obj.url}",
				function(loj) {
					$("#result").html(JSON.stringify(loj.attr("result")));
					format();
				});
	}
	
	function format() {
		var fmtCode = js_beautify($("#result").val(), 1, "", 5);
		$("#result").val(fmtCode);
	}
	</script>

</body>
</html>